//
//  JQTableView.m
//  AlertViewDemo
//
//  Created by 家琪 on 15/8/3.
//  Copyright (c) 2015年 JQ. All rights reserved.
//

#import "JQTableView.h"
#import "JQAlertView.h"

@interface JQTableView ()

@property NSArray *dataSource;

@end

@implementation JQTableView

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dataSource = @[@"Default",@"Drop down",@"Fly out",@"Flip horizontal"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    
    cell.textLabel.text = self.dataSource[indexPath.row];
    
    return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    JQAlertView *alert = [JQAlertView alertWithTitle:@"hahah" message:@"hahahah" clickBlock:^(JQAlertView *alert, NSInteger buttonIndex){
        NSLog(@"Index %ld",(long)buttonIndex);
    }];
    [alert showWithAnimation:indexPath.row];
}

@end
